{include file="public/header" /}


<div class="page">

    <form id="brand_form" action="{:url('Vouchertype/vouchertype_add')}" method="post">
        <table class="ds-default-table">
            <tbody>
            <tr class="noborder">
                <td class="required w120"><label class="validation">优惠券赠送类型:</label></td>
                <td class="vatop rowform">
                    <input type="text" id="send_name" name="send_name" value="{$adv.send_name}" class="txt">
                </td>
                <td class="vatop tips"></td>
            </tr>
            <tr class="noborder">
                <td class="required w120"><label class="validation">优惠劵:</label></td>
                <td class="vatop rowform">
                    <select name="voucher" id="voucher" style="width: 222px;">
                         <option value="">请选择</option>
                         {foreach name="voucher" item="cate"}
                         <option value="{$cate.voucher_id}">{$cate.voucher_title|default=''}</option>
                         {/foreach}
                    </select>
                </td>
                <td class="vatop tips"></td>
            </tr>
            <tr class="noborder">
                <td class="required w120"><label class="validation">优惠券发放条件:</label></td>
                <td class="vatop rowform">
                    <select name="vouchertype" id="ap_id">
                        <option value="">请选择</option>
                        <option value='1' {if condition="$adv.ap_id eq 1"}selected{/if}>新用户注册首次登录赠送</option>
                        <option value='2' {if condition="$adv.ap_id eq 2"}selected{/if}>定时发放</option>
                        <option value='3' {if condition="$adv.ap_id eq 3"}selected{/if}>下单满多少赠送</option>
                    </select>
                </td>
                <td class="vatop tips"></td>
            </tr>

            <tr class="noborder" id="full_price_info" style="display: none;">
                <td class="required w120"><label>下单满多少可用:</label></td>
                <td class="vatop rowform">
                    <input type="text" id="full_price" name="full_price" value="{$adv.full_price}" class="txt">
                </td>
                <td class="vatop tips"></td>
            </tr>

            <tr class="noborder" id="start_info" style="display: none;">
                <td class="required w120"><label>定时发放开始时间{$Think.lang.ds_colon}</label></td>
                <td class="vatop rowform">
                    <input id="start_time" value="{present name='xianshi_info'}{$xianshi_info.xianshi_starttime|date="Y-m-d H:i:s",###}{/present}" name="start_time" type="text" class="text w130"/><em
                        class="add-on"><i class="iconfont">&#xe8d6;</i></em><span></span>
                </td>
                <td class="vatop tips"></td>
            </tr>

            <tr class="noborder" id="end_info" style="display: none;">
                <td class="required w120"><label>定时发放结束时间{$Think.lang.ds_colon}</label></td>
                <td class="vatop rowform">
                    <input id="end_time" name="end_time" value="{present name='xianshi_info'}{$xianshi_info.xianshi_end_time|date="Y-m-d H:i:s",###}{/present}" type="text" class="text w130"/><em class="add-on"><i
                        class="iconfont">&#xe8d6;</i></em><span></span>
                </td>
                <td class="vatop tips"></td>
            </tr>

            <tr class="noborder">
                <td class="required w150"><label  for="ac_name">状态:</label></td>
                <td class="vatop rowform onoff">
                    <label for="brand_recommend1" class="cb-enable {if $adv.status == '1'}selected{/if}" title="{$Think.lang.ds_yes}"><span>启用</span></label>
                    <label for="brand_recommend0" class="cb-disable {if $adv.status == '0'}selected{/if}" title="{$Think.lang.ds_no}"><span>禁用</span></label>
                    <input id="brand_recommend1" name="status" {if $adv.status == '1'}checked="checked"{/if} value="1" type="radio">
                    <input id="brand_recommend0" name="status" {if $adv.status == '0'}checked="checked"{/if} value="0" type="radio"></td>
                </td>
            </tr>


            </tbody>
            <tfoot>
            <tr class="tfoot">
                <td colspan="15"><input style="line-height: 10px;" class="btn" type="submit" value="{$Think.lang.ds_submit}"/></td>
            </tr>
            </tfoot>
        </table>
    </form>

</div>
<link href="{$Think.PLUGINS_SITE_ROOT}/colorpicker/evol.colorpicker.css" rel="stylesheet" type="text/css">
<script src="{$Think.PLUGINS_SITE_ROOT}/colorpicker/evol.colorpicker.min.js"></script>
<link rel="stylesheet" href="{$Think.PLUGINS_SITE_ROOT}/js/jquery.lightbox/css/lightbox.min.css">
<script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery.lightbox/js/lightbox.min.js"></script>
<link rel="stylesheet" href="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/jquery-ui-timepicker-addon.min.css">
<script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/jquery-ui-timepicker-addon.min.js"></script>
<script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/i18n/jquery-ui-timepicker-zh-CN.js"></script>
<script type="text/javascript">
$(function(){
    $('#adv_startdate').datepicker({dateFormat: 'yy-mm-dd'});
    $('#adv_enddate').datepicker({dateFormat: 'yy-mm-dd'});
    $('#adv_bgcolor').colorpicker({showOn: 'both'});
        $("#file_adv_code").change(function () {
            $("#textfield1").val($("#file_adv_code").val());
        });
    $('#start_time').datetimepicker({dateFormat: 'yy-mm-dd'});
    $('#end_time').datetimepicker({dateFormat: 'yy-mm-dd'});

    $('#ap_id').change(function(){
        var type = $(this).children('option:selected').val();//这就是selected的值
        if(type == 1){
            $("#full_price_info").hide();
            $("#start_info").hide();
            $("#end_info").hide();
        }else if(type == 2){
            $("#full_price_info").hide();
            $("#start_info").show();
            $("#end_info").show();
        }else if(type == 3){
            $("#full_price_info").show();
            $("#start_info").hide();
            $("#end_info").hide();
        }
    });
});
$(function(){
    function nosubmit(c) {
        $(c).attr('disabled', 'true');
        $(c).css('background', '#eee');
    }
    function delnosubmit(c) {
        $(c).removeAttr('disabled');
        $(c).css('background', '');
    }
    $("#company_address").ds_region();
    $("#business_licence_address").ds_region();
    $("#bank_address").ds_region();
    $("#settlement_bank_address").ds_region();
    $('#end_time').datepicker({dateFormat: 'yy-mm-dd'});
    $('#business_licence_start').datepicker({dateFormat: 'yy-mm-dd'});
    $('#business_licence_end').datepicker({dateFormat: 'yy-mm-dd'});
});
</script>
<script>
    $(document).ready(function(){
        //页面输入内容验证
        $("#add_form").validate({
            errorPlacement: function(error, element){
                error.appendTo(element.parent().parent().find('td:last'));
            },

            rules : {
                promotion_xianshi_price: {
                    required : true,
                    digits : true,
                    min : 0
                }
            },
            messages : {
                promotion_xianshi_price: {
                    required : '{$Think.lang.xianshi_price_error}',
                    digits : '{$Think.lang.xianshi_price_error}',
                    min : '{$Think.lang.xianshi_price_error}'
                }
            }

        });
        $("form").submit(function(e){
            var res =  $("#brand_form").valid();
            var url = $('form').attr('action');
            $.ajax({
                type: "POST",
                url:url,
                data:$('#brand_form').serialize(),// 你的formid
                error: function(request) {
                    alert("Connection error");
                },
                success: function(result) {
                    if(result.code==0){
                        layer.msg(result.msg);
                        return false;
                    }else{
                        layer.msg(result.msg);
                        parent.location.reload();return false;
                    }
                }
            });
            return false;

        });
    });
</script> 